#include <cppunit/config/SourcePrefix.h>
#include "TestProcTableEntry.h"
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

void TestProcTableEntry::setUp() {
}

void TestProcTableEntry::tearDown() {
}

CPPUNIT_TEST_SUITE_REGISTRATION( TestProcTableEntry );

void TestProcTableEntry::testProcTableEntry(){
	ProcTableEntry entry("ProcX",0);
	CPPUNIT_ASSERT_EQUAL_MESSAGE("entry 0 created", 0, entry.getEntryNo());
	CPPUNIT_ASSERT_EQUAL_MESSAGE("name of entry is \"ProcX\"", string("ProcX"), entry.getName());
	CPPUNIT_ASSERT_MESSAGE("initial NodeIDs is not null and is empty", entry.getNodeIDs().empty());
}

void TestProcTableEntry::testAddNodeID(){
	ProcTableEntry entry("ProcX",0);
	entry.addNodeID(0);
	CPPUNIT_ASSERT_MESSAGE("entry NodeIDs contain 0", 
		find(entry.getNodeIDs().begin(),entry.getNodeIDs().end(),0) != entry.getNodeIDs().end());
	entry.addNodeID(1);
	CPPUNIT_ASSERT_MESSAGE("entry NodeIDs contain 0 and 1", 
							find(entry.getNodeIDs().begin(),entry.getNodeIDs().end(),0) != entry.getNodeIDs().end()
							&& find(entry.getNodeIDs().begin(),entry.getNodeIDs().end(),1) != entry.getNodeIDs().end());
	entry.addNodeID(1);
	CPPUNIT_ASSERT_EQUAL_MESSAGE("entry NodeIDs contain only 2 entries", 2, (int) entry.getNodeIDs().size());	
}